<?php
/**
 * CreateTime: 2023/7/17 10:11
 */

namespace App\Http\Controllers\Auth;

use App\Consts\TableConsts\TableConsts;
use App\Models\Auth\AuthBasicModel;
use App\Models\Auth\AuthMenuModel;
use Illuminate\Support\Facades\DB;

class AdminAuthController
{
    public function getAdminAuthList(){
        $authModel = new AuthBasicModel();
        // 复刻的大佬的SQL
        $query = $authModel::query()
            ->selectRaw('*')
            ->selectRaw('(SELECT menu_parent_id FROM cy_'.TableConsts::CY_AUTH_MENU_TABLE_NAME.' AS b WHERE b.menu_id= cy_'.TableConsts::CY_AUTH_AUTH_TABLE_NAME.'.menu_id) AS menu_parent_id')
            ->selectRaw('(SELECT menu_code FROM cy_'.TableConsts::CY_AUTH_MENU_TABLE_NAME.' AS b WHERE b.menu_id=cy_'.TableConsts::CY_AUTH_AUTH_TABLE_NAME.'.menu_id) AS menu_code')
            ->orderByDesc('menu_id');

        $results = DB::table(DB::raw('('.$query->toSql().') as a'))
            ->mergeBindings($query->getQuery())
            ->get();


    }



}